﻿@inject IStringLocalizer<Foo> LocalizerFoo

<Table TItem="Foo" Items="@Items" IsBordered="true" IsExcel="true" IsFixedHeader="true" Height="500">
    <TableColumns>
        <TableColumn @bind-Field="@context.Name" Width="200">
            <EditTemplate Context="row">
                <div class="d-flex disabled">
                    <div>
                        <img src="@Foo.GetAvatarUrl(row!.Id)" class="bb-avatar" />
                    </div>
                    <div class="ps-2">
                        <div>@row.Name</div>
                        <div class="bb-sub">@Foo.GetTitle(row!.Id)</div>
                    </div>
                </div>
            </EditTemplate>
        </TableColumn>
        <TableColumn @bind-Field="@context.Address" />
        <TableColumn @bind-Field="@context.Education" Width="160" />
        <TableColumn @bind-Field="@context.Count" Width="160">
            <EditTemplate Context="row">
                <div class="disabled">
                    <div>@row!.Count %</div>
                    <Progress Value="@row.Count" Color="@Foo.GetProgressColor(row.Count)"></Progress>
                </div>
            </EditTemplate>
        </TableColumn>
        <TableColumn @bind-Field="@context.Complete" Align="Alignment.Center" Width="80" />
    </TableColumns>
</Table>

@code {
    /// <summary>
    /// Foo 类为Demo测试用，如有需要请自行下载源码查阅
    /// Foo class is used for Demo test, please download the source code if necessary
    /// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
    /// </summary>
    [NotNull]
    private List<Foo>? Items { get; set; }

    /// <summary>
    /// OnInitialized 方法
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();

        Items = Foo.GenerateFoo(LocalizerFoo);
    }
}
